package com.lysj.bhp.withdraw.repository;

import com.lysj.bhp.util.web.SelectItem;
import com.lysj.bhp.withdraw.domain.WithDraw;
import com.lysj.bhp.withdraw.domain.WithDrawAddress;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface WithDrawAddressRepository extends JpaRepository<WithDrawAddress, Long>, JpaSpecificationExecutor {

    List<WithDrawAddress> findByUserIdAndTypeAndStatus(Long userId, int type, int status);

    List<WithDrawAddress> findByUserIdAndStatus(Long userId, int status);

    WithDrawAddress findByUserIdAndDefaultStatus(Long userId, int defaultStatus);

    WithDrawAddress findByUserIdAndDefaultStatusAndType(Long userId, int defaultStatus, int type);

    List<WithDrawAddress>  findByAddressAndUserIdAndTypeAndStatus(String address,Long userId,int type,int status);


    @Query("select new com.lysj.bhp.util.web.SelectItem(t.withDrawAddressId AS value,t.address AS name) from WithDrawAddress t where t.status=1 AND t.userId=?1 AND t.type=?2")
    List<SelectItem> selectItems(Long userId, int type);
}
